<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{$pagetitle}</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/admin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/admin/style/global.css" media="all">
  <style>
	  .layui-form-label{ width:10%;}
	  .layui-form-item .layui-input-inline{width: 80%;}
  </style>  
</head>
<body>
<form action="{:url()}" method="post" class="form-horizontal" onsubmit="return this_submit(this)">
	<input type="hidden" name="type" value="{$r.type}" />
	<input type="hidden" name="template_id" value="{$r.template_id}" />
  <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
      <label class="layui-form-label">模板名称</label>
      <div class="layui-input-inline">
        <input type="text" lay-verify="required" name="name" value="{$r.name}" autocomplete="off" class="layui-input">
      </div>
    </div>
	
	{if $r['type']=="public"}
    <div class="layui-form-item">
      <label class="layui-form-label">变量名</label>
      <div class="layui-input-inline">
		{include "<input type="text" name="myvar" autocomplete="off" style="width:100px; height: 30px; line-height: 30px; border: 0px; border-bottom: 1px #000000 solid;" value="{$r.myvar}" autocomplete="off"/>.html"} (如：header，变量就是{include "header.html"})
      </div>
    </div>	
	{/if}	
	
    <div class="layui-form-item">
      <label class="layui-form-label">模板内容</label>
      <div class="layui-input-inline"><textarea name="pagetext" id="template_editor"  class="span11" style="height:500px;">{$r.pagetext|raw}</textarea></div>
    </div>

	
	<div class="layui-form-item layui-layout-admin" style="margin-top: 30px;">
		<div class="layui-input-block">
		   <div class="layui-footer" style="left: 0;">
			  <button class="layui-btn" type="submit"  lay-filter="component-form-element" disabled="disabled">立即提交</button>
			  <button type="reset" class="layui-btn layui-btn-primary close">关闭</button>
			  <a type="button" href="{:url('PageHistory/index',array('page_id'=>$r['page_id']))}" class="layui-btn layui-btn-primary iframe" data-width="70%" data-height="80%"><i class="layui-icon layui-icon-time"></i>历史版本</a>
			  <a type="button" class="layui-btn layui-btn-primary"><i class="layui-icon layui-icon-dollar"></i>变量说明</a>
		  </div>
		</div>
	</div>  

  </div>
</form>
  <script src="/static/admin/layui/layui.js"></script>
  <script src="/static/js/jquery.min.js"></script>    
  <script src="/static/js/globals.js"></script>  
  <!--代码编辑器插件-->
  <link rel="stylesheet" type="text/css" href="/static/admin/codemirror/lib/codemirror.css">
  <script src="/static/admin/codemirror/lib/codemirror.js"></script>
  <link rel="stylesheet" href="/static/admin/codemirror/theme/abcdef.css">
  <script>
  layui.config({
    base: '/static/admin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
    var $ = layui.$
    ,form = layui.form;
  })
  
    var editor = CodeMirror.fromTextArea(document.getElementById("template_editor"), {
      lineNumbers: true,
      styleActiveLine: true,
      matchBrackets: true,
      theme:"abcdef",
    });  
	//还原代码更新
	function updateCode(){
	  editor.setValue($("#template_editor").val());
	}		
  </script>
</body>
</html>